//
//  VideoCell.swift
//  Swift30Days
//
//  Created by licheng ke on 2017/2/28.
//  Copyright © 2017年 licheng ke. All rights reserved.
//

import UIKit

struct MyVideo {
   let image,title,source : String
}

protocol VideoCellDelegate : NSObjectProtocol {
    func viewCellAction(_ myCell:VideoCell) ;
}

class VideoCell: UITableViewCell {
    
    @IBOutlet weak var videoImage: UIImageView!

    @IBOutlet weak var videoLabel: UILabel!
    
    var video : MyVideo?
    
    weak var delegate : VideoCellDelegate?
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }

   @IBAction  func playAction(_ sender: UIButton) {
        if delegate != nil
        {
            delegate?.viewCellAction(self);
        }
    }

    override func layoutSubviews() {
        super.layoutSubviews();
        if video != nil {
            self.videoImage.image = UIImage(named:video!.image);
            self.videoLabel.text = video!.title;
        }
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
